﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="FavoritesView.xaml.cs" company="R.V.Kasner">
//   Copyright © 2011 R.V.Kasner
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace Owen.Terminal.View
{
    using System;
    using System.Windows.Media;

    using Owen.Terminal.Properties;
    using Owen.Terminal.ViewModel;

    /// <summary>
    ///   Логика взаимодействия для FavoritesView.xaml
    /// </summary>
    public partial class FavoritesView : IFavoritesView
    {
        private bool isSel;

        public FavoritesView()
        {
            this.InitializeComponent();

            this.favoriteListView.FontFamily = new FontFamily(Settings.Default.FavoriteFontName);
            this.favoriteListView.FontSize = Settings.Default.FavoriteFontSize;
        }

        public event Action Selected;

        public bool IsSelected
        {
            get
            {
                return this.isSel;
            }

            set
            {
                this.isSel = value;
                if (this.isSel) this.RaiseSelected();
            }
        }

        public string Title
        {
            get
            {
                return "Избранное";
            }
        }

        public IViewModel ViewModel
        {
            get
            {
                return this.DataContext as IViewModel;
            }

            set
            {
                this.DataContext = value;
            }
        }

        private void RaiseSelected()
        {
            var a = this.Selected;
            if (a != null) a();
        }
    }
}